package com.partsoft.dits.log;

import java.util.Date;

import org.springframework.util.ClassUtils;

import com.partsoft.dits.EdgeDescriptor;

public abstract class AbstractLogManager implements LogManager {

	public void removeLog(LogLevel level) {
		doRemoveLog(null, level, null, null, null);
	}

	public void removeLog(LogType type) {
		doRemoveLog(type, null, null, null, null);
		
	}

	public void removeLog(LogType logType, LogLevel level) {
		doRemoveLog(logType, level, null, null, null);
	}

	public void removeLogBefore(Date beforeDate) {
		doRemoveLog(null, null, null, beforeDate, null);
	}

	public void removeLogBefore(LogType type, Date beforeDate) {
		doRemoveLog(type, null, null, beforeDate, null);
	}

	public void removeLogBefore(LogType type, LogLevel level, Date beforeDate) {
		doRemoveLog(type, level, null, beforeDate, null);
	}

	public void removeLogBefore(LogLevel level, Date beforeDate) {
		doRemoveLog(null, level, null, beforeDate, null);
	}

	public void removeLogAfter(Date afterDate) {
		doRemoveLog(null, null, afterDate, null, null);
	}

	public void removeLogAfter(LogType type, Date afterDate) {
		doRemoveLog(type, null, afterDate, null, null);
	}

	public void removeLogAfter(LogLevel level, Date afterDate) {
		doRemoveLog(null, level, afterDate, null, null);
	}

	public void removeLogAfter(LogType type, LogLevel level, Date afterDate) {
		doRemoveLog(type, level, afterDate, null, null);
	}

	public void removeLogBetween(Date startDate, Date endDate) {
		doRemoveLog(null, null, startDate, endDate, null);
	}

	public void removeLogBetween(LogType type, Date startDate, Date endDate) {
		doRemoveLog(type, null, startDate, endDate, null);
	}

	public void removeLogBetween(LogLevel level, Date startDate, Date endDate) {
		doRemoveLog(null, level, startDate, endDate, null);
	}

	public void removeLogBetween(LogType type, LogLevel level, Date startDate, Date endDate) {
		doRemoveLog(type, level, startDate, endDate, null);
	}
	
	public void removeLog(LogLevel level, String queryString) {
		doRemoveLog(null, level, null, null, queryString);
	}

	public void removeLog(LogType type, String queryString) {
		doRemoveLog(type, null, null, null, queryString);
	}

	public void removeLog(LogType logType, LogLevel level, String queryString) {
		doRemoveLog(null, level, null, null, queryString);
	}

	public void removeLogBefore(Date beforeDate, String queryString) {
		doRemoveLog(null, null, null, beforeDate, queryString);
	}

	public void removeLogBefore(LogType type, Date beforeDate, String queryString) {
		doRemoveLog(type, null, null, beforeDate, queryString);
	}

	public void removeLogBefore(LogType type, LogLevel level, Date beforeDate, String queryString) {
		doRemoveLog(type, level, null, beforeDate, queryString);
	}

	public void removeLogBefore(LogLevel level, Date beforeDate, String queryString) {
		doRemoveLog(null, level, null, beforeDate, queryString);
	}

	public void removeLogAfter(Date afterDate, String queryString) {
		doRemoveLog(null, null, afterDate, null, queryString);
	}

	public void removeLogAfter(LogType type, Date afterDate, String queryString) {
		doRemoveLog(type, null, afterDate, null, queryString);
	}

	public void removeLogAfter(LogLevel level, Date afterDate, String queryString) {
		doRemoveLog(null, level, afterDate, null, queryString);
	}

	public void removeLogAfter(LogType type, LogLevel level, Date afterDate, String queryString) {
		doRemoveLog(type, level, afterDate, null, queryString);
	}

	public void removeLogBetween(Date startDate, Date endDate, String queryString) {
		doRemoveLog(null, null, startDate, endDate, queryString);
	}

	public void removeLogBetween(LogType type, Date startDate, Date endDate, String queryString) {
		doRemoveLog(type, null, startDate, endDate, queryString);
	}

	public void removeLogBetween(LogLevel level, Date startDate, Date endDate, String queryString) {
		doRemoveLog(null, level, startDate, endDate, queryString);
	}

	public void removeLogBetween(LogType type, LogLevel level, Date startDate, Date endDate, String queryString) {
		doRemoveLog(type, level, startDate, endDate, queryString);
	}
	
	public void removeLog(EdgeDescriptor descriptor) {
		doRemoveLog(descriptor, null, null, null, null, null);
	}

	public void removeLog(EdgeDescriptor descriptor, LogLevel level) {
		doRemoveLog(descriptor, null, level, null, null, null);
	}

	public void removeLog(EdgeDescriptor descriptor, LogLevel level, String queryString) {
		doRemoveLog(descriptor, null, level, null, null, queryString);
	}

	public void removeLog(EdgeDescriptor descriptor, LogType type) {
		doRemoveLog(descriptor, type, null, null, null, null);
	}

	public void removeLog(EdgeDescriptor descriptor, LogType type, String queryString) {
		doRemoveLog(descriptor, type, null, null, null, queryString);
	}

	public void removeLog(EdgeDescriptor descriptor, LogType logType, LogLevel level, String queryString) {
		doRemoveLog(descriptor, null, level, null, null, null);
	}

	public void removeLogBefore(EdgeDescriptor descriptor, Date beforeDate) {
		doRemoveLog(descriptor, null, null, null, beforeDate, null);
	}

	public void removeLogBefore(EdgeDescriptor descriptor, Date beforeDate, String queryString) {
		doRemoveLog(descriptor, null, null, null, beforeDate, queryString);
	}

	public void removeLogBefore(EdgeDescriptor descriptor, LogType type, Date beforeDate) {
		doRemoveLog(descriptor, type, null, null, beforeDate, null);
	}

	public void removeLogBefore(EdgeDescriptor descriptor, LogType type, Date beforeDate, String queryString) {
		doRemoveLog(descriptor, type, null, null, beforeDate, queryString);
	}

	public void removeLogBefore(EdgeDescriptor descriptor, LogType type, LogLevel level, Date beforeDate) {
		doRemoveLog(descriptor, type, level, null, beforeDate, null);
	}

	public void removeLogBefore(EdgeDescriptor descriptor, LogType type, LogLevel level, Date beforeDate, String queryString) {
		doRemoveLog(descriptor, type, level, null, beforeDate, queryString);
	}

	public void removeLogBefore(EdgeDescriptor descriptor, LogLevel level, Date beforeDate) {
		doRemoveLog(descriptor, null, level, null, beforeDate, null);
	}

	public void removeLogBefore(EdgeDescriptor descriptor, LogLevel level, Date beforeDate, String queryString) {
		doRemoveLog(descriptor, null, level, null, beforeDate, queryString);
	}

	public void removeLogAfter(EdgeDescriptor descriptor, Date afterDate) {
		doRemoveLog(descriptor, null, null, afterDate, null, null);
	}

	public void removeLogAfter(EdgeDescriptor descriptor, Date afterDate, String queryString) {
		doRemoveLog(descriptor, null, null, afterDate, null, queryString);
	}

	public void removeLogAfter(EdgeDescriptor descriptor, LogType type, Date afterDate) {
		doRemoveLog(descriptor, type, null, afterDate, null, null);
	}

	public void removeLogAfter(EdgeDescriptor descriptor, LogType type, Date afterDate, String queryString) {
		doRemoveLog(descriptor, type, null, afterDate, null, queryString);
	}

	public void removeLogAfter(EdgeDescriptor descriptor, LogLevel level, Date afterDate) {
		doRemoveLog(descriptor, null, level, afterDate, null, null);
	}

	public void removeLogAfter(EdgeDescriptor descriptor, LogLevel level, Date afterDate, String queryString) {
		doRemoveLog(descriptor, null, level, afterDate, null, queryString);
	}

	public void removeLogAfter(EdgeDescriptor descriptor, LogType type, LogLevel level, Date afterDate) {
		doRemoveLog(descriptor, type, level, afterDate, null, null);
	}

	public void removeLogAfter(EdgeDescriptor descriptor, LogType type, LogLevel level, Date afterDate, String queryString) {
		doRemoveLog(descriptor, type, level, afterDate, null, queryString);
	}

	public void removeLogBetween(EdgeDescriptor descriptor, Date startDate, Date endDate) {
		doRemoveLog(descriptor, null, null, startDate, endDate, null);
	}

	public void removeLogBetween(EdgeDescriptor descriptor, Date startDate, Date endDate, String queryString) {
		doRemoveLog(descriptor, null, null, startDate, endDate, queryString);
	}

	public void removeLogBetween(EdgeDescriptor descriptor, LogType type, Date startDate, Date endDate) {
		doRemoveLog(descriptor, type, null, startDate, endDate, null);
	}

	public void removeLogBetween(EdgeDescriptor descriptor, LogType type, Date startDate, Date endDate, String queryString) {
		doRemoveLog(descriptor, type, null, startDate, endDate, queryString);
	}

	public void removeLogBetween(EdgeDescriptor descriptor, LogLevel level, Date startDate, Date endDate) {
		doRemoveLog(descriptor, null, level, startDate, endDate, null);
	}

	public void removeLogBetween(EdgeDescriptor descriptor, LogLevel level, Date startDate, Date endDate, String queryString) {
		doRemoveLog(descriptor, null, level, startDate, endDate, queryString);
	}

	public void removeLogBetween(EdgeDescriptor descriptor, LogType type, LogLevel level, Date startDate, Date endDate) {
		doRemoveLog(descriptor, type, level, startDate, endDate, null);
	}

	public void removeLogBetween(EdgeDescriptor descriptor, LogType type, LogLevel level, Date startDate, Date endDate, String queryString) {
		doRemoveLog(descriptor, type, level, startDate, endDate, queryString);
	}

	protected void doRemoveLog(LogType type, LogLevel level, Date startDate, Date endDate, String queryString) {
		doRemoveLog(null, type, level, startDate, endDate, queryString);
	}
	
	public void removeLog(String dclsName, String did) {
		doRemoveLog(dclsName, did, null, null, null, null, null);
	}

	public void removeLog(String dclsName, String did, LogLevel level, String queryString) {
		doRemoveLog(dclsName, did, null, level, null, null, queryString);
	}

	public void removeLog(String dclsName, String did, LogType type, String queryString) {
		doRemoveLog(dclsName, did, type, null, null, null, queryString);
	}

	public void removeLogBefore(String dclsName, String did, LogLevel level, Date beforeDate, String queryString) {
		doRemoveLog(dclsName, did, null, level, null, null, queryString);
	}

	public void removeLogAfter(String dclsName, String did, LogType type, LogLevel level, Date afterDate, String queryString) {
		doRemoveLog(dclsName, did, type, level, null, null, queryString);
	}

	public void removeLogBetween(String dclsName, String did, LogType type, LogLevel level, Date startDate, Date endDate, String queryString) {
		doRemoveLog(dclsName, did, type, level, startDate, endDate, queryString);
	}

	protected void doRemoveLog(EdgeDescriptor descriptor, LogType type, LogLevel level, Date startDate, Date endDate, String queryString) {
		String dclsName = null;
		String did = null;
		if (descriptor != null) {
			dclsName = ClassUtils.getUserClass(descriptor).getName();
			did = descriptor.getId();
		}
		doRemoveLog(dclsName, did, type, level, startDate, endDate, queryString);
	}
	
	protected abstract void doRemoveLog(String dclsName,  String did, LogType type, LogLevel level, Date startDate, Date endDate, String queryString);

}
